<!DOCTYPE html>
<html>
<head>
	<title></title>
	<link href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
	<link href="http://cdn.gbtags.com/twitter-bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body onload="show()">
<div class="container-fluid">
	<button class="btn" type="button" name="index" style="background: #00b4ef; position: absolute; top: 15px;right: 50px;"><a href="/Home/Login/login">首页</a></button>
	<button class="btn" type="button" name="index" style="background: #86db00; position: absolute; top: 50px;right: 50px;"><a href="/Home/Hard/index">回退</a></button>
	<div class="row-fluid">
		<div class="span12">
			<h1>固件更新</h1>
			<ul class="nav nav-tabs">
				<li>
				<li class="active">
					<a href="#">白名单管理</a>
				</li>
			</ul>
		</div>
	</div>
	<table class="table">
		<thead>
		<tr>
			<th>
				ID
			</th>
			<th>
				Name
			</th>
			<th>
				Type
			</th>
			<th>
				序列号
			</th>
			<th>
				型号
			</th>
			<th>
				责任人
			</th>
			<th>
				生成时间
			</th>
		</tr>
		</thead>
		<tr style="visibility: hidden" name="hidden">
			<th>
			</th>
			<th>
				<input  type="text" class="newname"   placeholder="名字">
			</th>
			<th>
				<input  type="text" class="newtype"   placeholder="类型">
			</th>
			<th>
				<input  type="text" class="newserial"   placeholder="序列号">
			</th>
			<th>
				<input  type="text" class="newmodel" placeholder="型号">
			</th>
			<th>
				<input  type="text" class="newperson"   placeholder="责任人">
			</th>
			<th>
			</th>
			<th>
				<button class="btn btn-success" type="button" >添加</button>
			</th>
		</tr>
		<tbody>
		<volist name="data" id="ls">
			<tr>
				<td>
					{$ls.id}
				</td>
				<td>
					<input type="text" class="name" name="name" value="{$ls.name}">
				</td>
				<td>
					<input type="text" class="type" name="type" value="{$ls.type}">
				</td>
				<td>
					<input type="text"  class="serial" name="serial" value="{$ls.serial}">
				</td>
				<td>
					<input type="text"  class="model" name="model" value="{$ls.model}">
				</td>
				<td>
					<input type="text" class="person" name="person" value="{$ls.person}">
				</td>
				<td>
					{$ls.time}
				</td>
				<td>
					<div style="visibility: hidden" name="hidden">
						<button class="btn btn-warning" type="button" id="save" name="{$ls.id}">修改</button>
						<button class="btn btn-danger" type="button" name="{$ls.id}" onclick="remove(this.name)">删除</button>
					</div>
				</td>
			</tr>
		</volist>
		</tbody>

	</table>
	<div class="page" style="text-align: center;" >
		{$_page}
	</div>

</div>

</body>




<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="bootstrap-table-zh-CN.js"></script>

<script type="text/javascript">

    $(function () {
        $(".btn-warning").click(function(){
            var r=confirm("确认修改？");
            if(r == true){
                var id = document.getElementById('save').name;
                var name = $(this).parent().parent().find(".name").val();
                var type = $(this).parent().parent().find(".type").val();
                var serial = $(this).parent().parent().find(".serial").val();
                var model = $(this).parent().parent().find(".model").val();
                var person = $(this).parent().parent().find(".person").val();
                $.post('/Home/Hard/white_save',{id:id,name:name,type:type,serial:serial,model:model,person:person},function(data){
                    if (data.status > 0) {
                        alert('修改成功！');
                        window.location.reload();
                    } else {
                        alert('修改失败！');
                        window.location.reload();
                    }
                })
            }
        })

    })

    $(function () {
        $(".btn-success").click(function(){
            var r=confirm("确认添加？");
            if(r == true){
                var name = $(this).parent().parent().find(".newname").val();
                var type = $(this).parent().parent().find(".newtype").val();
                var serial = $(this).parent().parent().find(".newserial").val();
                var model = $(this).parent().parent().find(".newmodel").val();
                var person = $(this).parent().parent().find(".newperson").val();
                $.post('/Home/Hard/white_add',{name:name,type:type,serial:serial,model:model,person:person},function(data){
                    if (data.status > 0) {
                        alert('添加成功！');
                        window.location.reload();
                    } else {
                        alert('添加失败！');
                        window.location.reload();
                    }
                })
            }
        })

    })

    function remove(eve){
        var r=confirm("确认删除？");
        if(r == true){
            var id = eve;
            $.post('/Home/Index/white_del',{id:id},function(data){
                if (data.status > 0) {
                    alert('删除成功！');
                    window.location.reload();
                } else {
                    alert('删除失败！');
                    window.location.reload();
                }
            })
        }


    }
    function eventshelf(eve){
        var r=confirm("确认？");
        if(r ==true){
            var id = eve;
            $.post('/Home/Hard/shelf',{id:id},function(data){
                if (data.status > 0) {
                    alert('下线成功！');
                    window.location.reload();
                } else {
                    alert('下线失败！');
                    window.location.reload();
                }
            })
        }
    }

    function show() {
        var arr = document.getElementsByName('hidden');
        var aut="{:session('whitelist')}";
        if(aut == true) {
            for(var i=0;i<arr.length;i++){
                arr[i].style.visibility = 'visible';
            }
        }
    }
</script>

</html>